<template>
  <li>
    <p class="title">
      <span>{{num}}.</span>{{data.title}}
    </p>
    <p>
      <el-radio v-model="answer" label="正确" :disabled="type == 'readonly'">正确</el-radio>
      <el-radio v-model="answer" label="错误" :disabled="type == 'readonly'">错误</el-radio>
    </p>
    <div v-if="type == 'readonly'" style="background-color: #f3f3f3;padding: 20px">
      <p>正确答案：{{data.trueAnswer}}</p>
      <p>你的答案：{{data.userAnswer}}</p>
      <p>描述：{{data.expound}}</p>
    </div>
    <el-divider></el-divider>
  </li>
</template>

<script>
export default {
    props:["data","num", "lastAnswer"],
    data() {
        return {
          // 将刷新前的数据进行赋值
          answer: this.lastAnswer ?? null,
          type: this.$route.query.type,

        }
    },
    watch: {
      answer: function(val) {
        const temp = {
          index: Number(this.num) - 1,
          data: val,
        }
        this.$store.commit("saveAnswerJudge", temp);
      }
    },
};
</script>

<style lang="scss" scoped>
li {
  list-style: none;
  .title {
    span {
      color: #63b1fe;
    }
  }
  p {
    padding-left: 15px;
  }
}
</style>
